﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using JKF.DataModule.SqlServerDAL;
using JKF.Substructure;

namespace JKF.BusinessLayer.BLL
{
    public partial class bllGIFT_TYPE
    {
         /// <summary>
        /// 获取礼品类别列表
        /// </summary>
        /// <param name="NAME">礼品类别名称</param>
        /// <param name="pageCurrent">当前页码</param>
        /// <param name="pageSize">一页显示多少</param>
        /// <param name="pageCount">总页数</param>
        /// <param name="rowCount">总记录数</param>
        /// <returns>返回DataTable数据</returns>
        public  DataTable GetGift_TypesBLL(string NAME, int pageCurrent, int pageSize, ref int pageCount, ref int rowCount)
        {
            return dalGIFT_TYPE.GetGift_TypesDAL(NAME, pageCurrent, pageSize, ref pageCount, ref rowCount);
        }
        /// <summary>
        /// 判断是否存在此名称,true表示存在
        /// </summary>
        /// <param name="shop_name">店面名称</param>
        /// <returns></returns>
        public  bool ExistsGift_TypeNameBLL(string gift_type_name)
        {
            return dalGIFT_TYPE.ExistsGift_TypeNameDAL(gift_type_name);
        }

        /// <summary>
        /// 取得礼品类别列表,保存到缓存cache中
        /// </summary>
        /// <returns></returns>
        public string GetGIFT_TYPE()
        {
            const string cacheName = "GIFT_TYPEOne";
            if (!CacheManage.HadCache(cacheName))
            {
                var oList = this.GetModelList("");

                var sb = new StringBuilder();
                foreach (var item in oList)
                {
                    sb.AppendFormat("<option value=\"{0}\">{1}</option>", item.GIFT_TPYE_KEY, item.NAME);
                }

                CacheManage.AddCache(cacheName, sb.ToString());
            }

            return CacheManage.GetCache(cacheName).ToString();
        }
    }
}
